home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / CFGUPD.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  114 lines

  1. //--------------------------------------------------------------------
  2. // The Aurora Editor v3.0, Copyright (C) 1993-1996 nuText Systems
  3. //
  4. // CFGUPD.AML
  5. //
  6. // Save the current configuration to Config.aml and Color.aml and
  7. // recompile the editor
  8. //--------------------------------------------------------------------
  9.  
  10. include bootpath "define.aml"
  11.  
  12. // load config.aml
  13. file = bootpath "config.aml"
  14. if not loadbuf file then
  15.   msgbox "Can't Open " + file  "Error!"
  16.   return
  17. end
  18.  
  19. // do for each variable in Config.aml
  20. loop
  21.  
  22.   // find the config variable
  23.   len = find "^ *public" 'x'
  24.   if len then
  25.     right len
  26.     nlength = find "[a-zA-Z0-9_]#" 'xl'
  27.     if nlength then
  28.  
  29.       // get config variable name and current value
  30.       varname = gettext (getcol) nlength
  31.       value = prf [varname]
  32.  
  33.       right nlength
  34.       if (find "=" 'l') and (find "[~ ]" 'xl') then
  35.         startcol = getcol
  36.         if (find "//" 'rlg') and (find "[~ ]" 'xr') then
  37.           endcol = getcol
  38.           col startcol
  39.  
  40.           // delete the old value
  41.           delchar endcol - startcol + 1
  42.  
  43.           // insert the new (current) value
  44.           if not length value then
  45.             instext "''"
  46.           elseif posnot "0-9" value then
  47.             value = sub '\\' '\\\\' value
  48.             value = sub '"' '\\"' value
  49.             instext '"' + value + '"'
  50.           else
  51.             instext value
  52.           end
  53.         end
  54.       end
  55.     end
  56.   else
  57.     break
  58.   end
  59. end
  60.  
  61. // save the new Config.aml
  62. if not (savebuf file) then
  63.   msgbox "Error saving " + file "Error!"
  64.   destroybuf
  65.   return
  66. end
  67. destroybuf
  68.  
  69. // define an array of color attribute names
  70. attrname = { "black"     "blue"        "green"        "cyan"
  71.              "red"       "magenta"     "brown"        "gray"
  72.              "darkgray"  "brightblue"  "brightgreen"  "brightcyan"
  73.              "brightred" "pink"        "yellow"       "white" }
  74.  
  75. // function to return foreground on background string for attr
  76. // (used to modify color.aml files)
  77. private function fattrname (attr)
  78.   attrname [(attr & 0fh) + 1]:-13 + "on " +
  79.     attrname [((attr & 0f0h) shr 4) + 1]:-13
  80. end
  81.  
  82.  
  83. // load color.aml
  84. file = bootpath "color.aml"
  85. if not loadbuf file then
  86.   msgbox "Can't Open " + file  "Error!"
  87.   return
  88. end
  89.  
  90. // do for each palette item in Color.aml
  91. for i = 1 to 100 do
  92.   len = find "^ *color.*//" 'x'
  93.   if len then
  94.     col (getlinebeg)
  95.     delchar len - (getcol - 1)
  96.     instext "color " + (fattrname (getpalette i)) + "//"
  97.   else
  98.     break
  99.   end
  100. end
  101.  
  102. // save the new Color.aml
  103. if not (savebuf file) then
  104.   msgbox "Error saving " + file "Error!"
  105.   destroybuf
  106.   return
  107. end
  108. destroybuf
  109.  
  110. // recompile the editor
  111. if not regen then
  112.   msgbox "Configuration has been saved."
  113. end
  114.